From 77afb8b283d2bfc7278f39c483dc5354fe87a70a Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Thu, 15 Mar 2007 22:15:12 +0000 Subject: [PATCH] Raise the VM_BAD_POWER_STATE error with VM.send_sysrq if the domain is not running. Signed-off-by: Ewan Mellor --- tools/python/xen/xend/XendAPI.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/python/xen/xend/XendAPI.py b/tools/python/xen/xend/XendAPI.py index 10024070a9..cb444f04d1 100644 --- a/tools/python/xen/xend/XendAPI.py +++ b/tools/python/xen/xend/XendAPI.py @@ -1515,11 +1515,16 @@ class XendAPI(object): "domain_unpause", vm_ref) def VM_send_sysrq(self, _, vm_ref, req): - xendom = XendDomain.instance() - xeninfo = xendom.get_vm_by_uuid(vm_ref) + xeninfo = XendDomain.instance().get_vm_by_uuid(vm_ref) + if xeninfo.state != XEN_API_VM_POWER_STATE_RUNNING: + return xen_api_error( + ['VM_BAD_POWER_STATE', vm_ref, + XendDomain.POWER_STATE_NAMES[XEN_API_VM_POWER_STATE_RUNNING], + XendDomain.POWER_STATE_NAMES[xeninfo.state]]) xeninfo.send_sysrq(req) return xen_api_success_void() + # Xen API: Class VM_metrics # ---------------------------------------------------------------- -- 2.30.2